package com.zhang.hadoop.netty.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author: zhang yufei
 * @create: 2022-01-22 16:21
 * @description:
 **/
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {


    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //向管道加入处理器
        //得到管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        //加入一个netty提供的httpServerCodec
        //1.httpServerCodec是netty体哦那个的http的编码解码器
        pipeline.addLast("HttpServerCodec", new HttpServerCodec());
        //2.增加一个自定义的handler
        pipeline.addLast("TestHttpServerHandler", new TestHttpServerHandler());
    }
}
